package com.giaothong.controller;

import org.json.JSONObject;

import android.content.Context;

import com.giaothong.http.HttpGetDirectionRequest;
import com.giaothong.http.HttpGetLocationInfoGoogleAPIRequest;
import com.giaothong.http.HttpSearchLocationFromTextRequest;
import com.giaothong.http.core.HttpAsyncCallback;
import com.google.android.maps.GeoPoint;

public class GoogleApiController {

	/**
	 * get Direction Controlller
	 * 
	 * @param context
	 * @param callback
	 * @param startLocation
	 * @param endLocation
	 * @param method
	 * @param sensor
	 */
	public static void getDirection(Context context, HttpAsyncCallback<JSONObject> callback, GeoPoint startLocation, GeoPoint endLocation, String method, boolean sensor) {
		HttpGetDirectionRequest httpGetDirectionRequest = new HttpGetDirectionRequest(context, callback);
		httpGetDirectionRequest.request(startLocation, endLocation, method, sensor);
	}

	/**
	 * search Location from Google Api
	 * 
	 * @param context
	 * @param callback
	 * @param location
	 * @param radius
	 * @param type
	 */
	public static void searchLocationFromGeoPoint(Context context, HttpAsyncCallback<JSONObject> callback, GeoPoint location, String radius, String type) {
		HttpGetLocationInfoGoogleAPIRequest httpGetLocationInfoGoogleAPIRequest = new HttpGetLocationInfoGoogleAPIRequest(context, callback);
		httpGetLocationInfoGoogleAPIRequest.request(location, radius, type);
	}

	/**
	 * search location request
	 * 
	 * @param context
	 * @param callback
	 * @param keyWord
	 * @param type
	 */
	public static void searchLocationFromText(Context context, HttpAsyncCallback<JSONObject> callback, String keyWord, String type, boolean isShowDialog) {
		HttpSearchLocationFromTextRequest httpSearchLocationFromTextRequest = new HttpSearchLocationFromTextRequest(context, callback);
		httpSearchLocationFromTextRequest.setIsShowProgressDialogWhenLoading(isShowDialog);
		httpSearchLocationFromTextRequest.request(keyWord, type);
	}

}
